<script setup lang="ts">
import moment from 'moment';
// import { DArrowLeft } from "@element-plus/icons";
import { ref, toRef } from "vue";
interface ListInterface {
    name: string | number,
    id: string | number

}
let num = ref(10)
let times = ref(1000)

const arrs = ref<ListInterface[]>([])
function sleep(time: number) {
    return new Promise(function (resolve) {
        setTimeout(resolve, time);
    });
}

const gonum = async (num: number, time: number): Promise<any> => {
    await sleep(52)
    if (num) {
        console.log('开始')
        for (let i = 0; i < num; i++) {
            try {
                await sleep(time)
                let arrsitem: ListInterface = {
                    name: i,
                    id: moment().format("x")
                }
                arrs.value.push(arrsitem)
                console.log(i, moment().format("x"))
            } catch (e) {
                console.log(e)

            }
        }
        console.log('结束')
    }
    await sleep(time)
    console.log('255582')
    return null
}

// let fun  = function(ele){
//     console.log(ele)
// }
// fun(2555)

// JSON.parse(JSON.stringify(arr))
let httpsFetch = async function (e: Number[]) {
    let arr = e.join()
    const url = `https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=${arr}&key=8bbec3514cb5339c5ac2f99da89b2816&radius=200&extensions=all`;
    try {
        let data = await (await fetch(url)).json()
        console.log(data)
        // console.log()
    } catch (err) {
        console.log(err)
    }
}
httpsFetch([30, 120])
</script>
<template>
    <div class="common-layout">
        <div class="w-full h-[calc(100dvh-80px)] bg-slate-300 ">
            <el-input v-model="num" style="width: 200px;" placeholder="请输入执行次数" clearable />

        </div>
        <!-- <div class="w-64 h-12 bg-slate-300 ">
            <el-input v-model="times" style="width: 200px;" placeholder="请输入执行间隔" clearable />
        </div>
        <div v-for="item in arrs " :key="item.id" class="w-64 h-12 bg-blue-300 ">
            {{ item.name }}---{{ item.id }}
        </div>
        <div class="w-1/2 h-12 bg-slate-300 ">
            <el-button @click="gonum(num, times)">确认</el-button>
        </div> -->
    </div>
</template>

<style scoped lang="scss">
.common-layout {
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    background-color: #fff;

}
</style>
